//
//  DaLiCell.m
//  Full_House
//
//  Created by 陈杰 on 15/6/5.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "DaLiCell.h"
#import "DanLi.h"
@interface DaLiCell ()

@property (nonatomic, retain) UIImageView *phohoImage;
@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UILabel *consultLabel;
@property (nonatomic, retain) UIImageView *starImage;
@property (nonatomic, retain) UILabel *likeNumLabel;

@end

@implementation DaLiCell

- (void)dealloc{
    [_daLi release];
    [_phohoImage release];
    [_nameLabel release];
    [_consultLabel release];
    [_starImage release];
    [_likeNumLabel release];
    [super dealloc];
    
}


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.phohoImage = [[UIImageView alloc] init];
        [self.contentView addSubview:_phohoImage];
        [_phohoImage release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        
        self.consultLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_consultLabel];
        [_consultLabel release];
        
        self.starImage = [[UIImageView alloc] init];
        _starImage.image = [UIImage imageNamed:@"iconfont-shoucang.png"];
        [self.contentView addSubview:_starImage];
        [_starImage release];
        
        self.likeNumLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_likeNumLabel];
        [_likeNumLabel release];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    _phohoImage.frame = CGRectMake(0, 0, layoutAttributes.bounds.size.width, 150);
    _nameLabel.frame = CGRectMake(10, 160, layoutAttributes.bounds.size.width, 20);
    _nameLabel.textAlignment = NSTextAlignmentLeft;
    _consultLabel.frame = CGRectMake(10, 200 - 20, 100, 20);
    _consultLabel.text = @"询价";
    _consultLabel.textAlignment = NSTextAlignmentLeft;
    
    _starImage.frame = CGRectMake(layoutAttributes.bounds.size.width - 50, 180, 15, 15);
    
    _likeNumLabel.frame = CGRectMake(layoutAttributes.bounds.size.width - 30, 180, 15, 15);
    
}

- (void)setDaLi:(DanLi *)daLi
{
    if (_daLi != daLi) {
        [_daLi release];
        _daLi = [daLi retain];
    }
    NSURL *url = [NSURL URLWithString:self.daLi.images];
    [_phohoImage setImageWithURL:url];
    
    _nameLabel.text = self.daLi.title;
    self.likeNumLabel.text = [NSString stringWithFormat:@"%ld", (long)self.daLi.likeNum];
    NSLog(@"nnds");
    
}





@end
